<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.test.util.PageUtil"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	PageUtil pageUtil=(PageUtil)request.getAttribute("pageUtil");
	int currentPage=0;
	int allPage=0;
	int nextPage=0;
	int lastPage=0;
	if(null != pageUtil)
	{
		currentPage=pageUtil.getCurrentPage(); 
		allPage=pageUtil.getAllPage();
		
		nextPage=(currentPage+1>allPage)?allPage:(currentPage+1);
		lastPage=(currentPage-1<1)?1:(currentPage-1);
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>购物记录</title>
<script type="text/javascript">
   var xmlHttpRequest;

	function createXmlRequest()
	{
		if(window.ActiveXObject)//如果是IE浏览器
		{
			xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			xmlHttpRequest=new XMLHttpRequest();
		}
	}

	var Number;
	var divId;
	function orderNumber(Num,divid)
	{
		divId=divid;//用于显示信息的div对象
		Number=Num;//获取点单编号
		createXmlRequest();
		xmlHttpRequest.onreadystatechange=dealCheckRegResult;
		xmlHttpRequest.open("GET","user4!QueryNumber.action?number="+Number,true);
		xmlHttpRequest.send(null);
	}
	
	function dealCheckRegResult()
	{
		if(xmlHttpRequest.readyState==4)
		{
			if(xmlHttpRequest.status==200)
			{
				var xmlStr=xmlHttpRequest.responseXML;
             
				var table=document.createElement("table");
				//表头
				var headStr="<tr><th>商品名称</th><th>单价</th><th>数量</th><th>小计</th></tr>";
				//table.innerHTML=headStr;
				//alert(table.outerHTML);

				//订单详情
				var detailList=xmlStr.getElementsByTagName("orderdetail");
				//getElementsByTagName
				alert(detailList.length);
				for(var i=0;i<detailList.length;i++)
				{
					var detailNode=detailList[i];
					var detailTr=document.createElement("tr");
					var detailStr="";
					var nodes=detailNode.childNodes;
					for(var j=0;j<nodes.length;j++)
					{
						if(nodes[j].nodeType==3)//文本节点
						{
							detailStr+="<td>"+nodes[j].nodeValue+"</td>";
						}
					}
					detailTr.innerHTML=detailStr;
					alert(detailTr.outerHTML);
					//table.appendChild(detailTr);
				}
				//alert(table.innerHTML);
				//divId.appendChild(table);

				//分割线
				var hr=document.createElement("hr");
				hr.style.border="0.5px dashed";
				divId.appendChild(hr);
				
				//余额
				var money=document.createElement("div");
				money.innerHTML="帐户余额：￥"+xmlStr.getElementsByTagName("money")[0].firstChild.nodeValue;
				divId.appendChild(money);
			}
		}
	}
</script>
<link  href="css/style.css"  rel="stylesheet" type="text/css"/>
</head>
<body>
<div  class="page">
<div  class="welcome wuser2">用户购物记录列表 </div>
<div class="list">
  <ul >
  	<li style="font-weight:bold;
	border-bottom:1px solid black;margin-left:5px;">编号</li>
	<li style="font-weight:bold;
	border-bottom:1px solid black;margin-left: 35px;">订单编号</li>
    <li style="font-weight:bold;
	border-bottom:1px solid black;margin-left:145px;">&nbsp;&nbsp;时间</li>
	<li style="font-weight:bold;
	border-bottom:1px solid black;margin-left:195px;">&nbsp;操作</li>
  </ul>
  
  <div  style="clear:both"></div>
  <!--重复的部分-->
    <c:forEach items="${orderlist}" var="cart" varStatus="vs">
  <ul class="row">
    <li style="margin-left: 3px;">${cart.id}</li>
	<li style="margin-left: 25px;"><span style="color:red;">${cart.orderId}</span></li>
    <li style="margin-left: 45px;">${cart.createTime}</li>
    <li style="margin-left: 130px;"><a href="javascript:orderNumber(${cart.orderId},orderId${vs.index });">详细</a></li>
  </ul>
  <div id="orderId${vs.index}"></div>
    </c:forEach>
  <div style="margin-left: 100px;">
		<a href="cart!shopcart.action?curpage1=1">首页</a>&nbsp;&nbsp;
		<a href="cart!shopcart.action?curpage1=<%=lastPage%>">上页</a>&nbsp;&nbsp;
		<a href="cart!shopcart.action?curpage1=<%=nextPage%>">下页</a>&nbsp;&nbsp;
		<a href="cart!shopcart.action?curpage1=${pageUtil.allPage}">末页</a>&nbsp;&nbsp;
		<a href="#">第${pageUtil.currentPage}页/共${pageUtil.allPage}页</a>
  </div>
<%--  <div class="row">--%>
<%--   --%>
<%--      <ul>--%>
<%--        <li class="colB rowTitle">商品名称</li>--%>
<%--        <li class="colS rowTitle">单价</li>--%>
<%--        <li class="colS rowTitle">数量</li>--%>
<%--        <li class="colS rowTitle">小计</li>--%>
<%--      </ul>--%>
<%--	<div  style="clear:both"></div>--%>
<%--      <ul>--%>
<%--        <li class="colB td">魔兽世界30元点卡</li>--%>
<%--        <li class="colS td">25</li>--%>
<%--        <li class="colS td">1张</li>--%>
<%--        <li class="colS td">25</li>--%>
<%--      </ul>--%>
<%--	    <div  style="clear:both"></div>--%>
<%--    <!--本次订单结束后的帐户余额-->--%>
<%-- 	<div class="lastRow" style="text-align:right">帐户余额：<span style="color:red;">￥0.00</span>元 </div>--%>
<%--	<!--结束-->--%>
　</div>
<!--重复部分end-->
</div>
</div>
</body>
</html>

